package ru.amse.jsynchro.logging;

public abstract class Logger implements ILogger {
    private static long startTime = System.currentTimeMillis();
    protected boolean useTime = false;
    protected boolean useSource = false;
    private String source;
    
    public Logger(boolean useTime, String source) {
        this.useTime = useTime;
        this.source = source;
    }
    
//    protected boolean useTime() {
//        return useTime;
//    }
    
    protected String preLogMessage() {
        StringBuilder stringBuilder = new StringBuilder();
        if (useTime) {
            stringBuilder.append(getTime());
        }
        if (useSource) {
            stringBuilder.append(source + " ");
        }
        
        return stringBuilder.toString();
    }

    public void setUseTime(boolean useTime) {
        this.useTime = useTime;
    }

    protected String getTime() {
        return ((double) (System.currentTimeMillis() - startTime) / 1000) + " sec: ";
    }
    
    public abstract void info(String message);
    public abstract void exception(Exception e);
}
